package com.liao;

import com.fasterxml.jackson.databind.ObjectMapper;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.slf4j.LoggerFactory;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

@Order(1)
@Component
@Aspect
public class Aspect1 {


    //定义一个切面
    @Pointcut(value = "execution(* com.liao.controller..*(..)) ")
    public void pointCut1() {

    }

    @Around("pointCut1()")
    public Object countTime(ProceedingJoinPoint joinPoint) throws Throwable {
        String className = joinPoint.getClass().toString();//获取类 class
        String methodName = joinPoint.getSignature().getName();//获取方法名
        Object objs = joinPoint.getArgs();//获取传入参数
        ObjectMapper mapper = new ObjectMapper();//用来展示参数或者结果
        Object obj = joinPoint.proceed();// 运行方法
        return "Aspect1";
    }
}